package com.bean;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

public class CdyOrder implements Serializable {

    private  Integer id;
    private String phone;
    private  String content;
    private  Double totalPrice;
    private  Integer state;
    private Date orderTime;
    private Integer spare;

    private List<Detail> details;

    public CdyOrder(Date orderTime) {
        this.orderTime = orderTime;
    }

    public CdyOrder() {
    }

    public CdyOrder(Integer id) {
        this.id = id;
    }

    public CdyOrder(String phone, String content, Double totalPrice, Integer state,
                    Date orderTime, Integer spare) {
        this.phone = phone;
        this.content = content;
        this.totalPrice = totalPrice;
        this.state = state;
        this.orderTime = orderTime;
        this.spare = spare;
    }

    public CdyOrder(Integer id, String phone, String content,
                    Double totalPrice, Integer state, Date orderTime, Integer spare) {
        this.id = id;
        this.phone = phone;
        this.content = content;
        this.totalPrice = totalPrice;
        this.state = state;
        this.orderTime = orderTime;
        this.spare = spare;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getContent() {
        return content;
    }

    public void setContent() {
        //设置订单内容
        Double total = 0.0;
        this.content = "";
        for (Detail recordDetail : this.details){
            this.content += recordDetail.getCommodity().getCdyName() + "," +
                    recordDetail.getNumber() + "份,单价" + recordDetail.getCommodity().getPrice() + "元";
            total += recordDetail.getCommodity().getPrice() * recordDetail.getNumber();
        }
        this.content += "\n\t合计:" + total;
        this.totalPrice = total;

    }

    public Double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(Double totalPrice) {
        this.totalPrice = totalPrice;
    }


    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(Date orderTime) {
        this.orderTime = orderTime;
    }

    public Integer getSpare() {
        return spare;
    }

    public void setSpare(Integer spare) {
        this.spare = spare;
    }

    public List<Detail> getDetails() {
        return details;
    }

    public void setDetails(List<Detail> details) {
        this.details = details;
    }

    @Override
    public String toString() {
        return "CdyOrder{" +
                "id=" + id +
                ", phone='" + phone + '\'' +
                ", content='" + content + '\'' +
                ", totalPrice=" + totalPrice +
                ", state=" + state +
                ", orderTime=" + orderTime +
                ", spare=" + spare +
                ", details=" + details +
                '}';
    }
}
